package com.shujia.utils

import org.apache.spark.sql.SparkSession

object SparkTool {
  def getSparkSession(appName: String): SparkSession = {

    var spark: SparkSession = null

    if (Constants.IS_LOCAL) {
      spark = SparkSession
        .builder()
        .appName(appName)
        .master("local")
        .config("spark.sql.shuffle.partitions", "1")
        .getOrCreate()
    } else {
      spark = SparkSession
        .builder()
        .appName(appName)
        .getOrCreate()
    }

    spark
  }

}
